\vssub
\subsection{~The wave model routines} \label{sec:core}
\vssub

The wave model driver is a subroutine within the \ws\ framework package. 
To run the model driver subroutine, a program shell is needed. 
\ws\ is provided with a simple stand-alone shell as
will be discussed in \para\ref{sec:ww3shel}, and with a more complex
multi-grid model shell as will be discussed in \para\ref{sec:ww3multi}. The
present section concentrates on the wave model driver subroutines.

The wave model initialization routine {\F w3init} performs model
initialization for a single wave model grid. This includes setting up part of
the I/O system by defining unit numbers, initializing internal time
management, processing the model definition file ({\file mod\_def.ww3}),
processing initial conditions ({\file restart.ww3}), preparing model output,
and calculating grid-dependent parameters. If the model is compiled for an
\mpi\ environment, all necessary communication for both calculations and
output are determined and initialized (the model uses persistent \mpi\
communication throughout).

The wave model routine {\F w3wave} can be called any number of times to
propagate the wave field for a single grid in time after the initialization
has taken place. After some initial checks, the subroutine interpolates winds
and currents, updates ice concentrations and water levels, propagates the wave
field, and applies the selected source terms for a number of time steps. The
internal time step is defined by the interval for which the calculations are
to be performed, and by the requested output times. At the end of the
calculations, the routine provides the calling program with the requested
fields of wave data. A documentation of the interface of {\F w3wave} can be
found in the source code ({\file w3wavemd.ftn}).

\input{run/fig_log.tex} 

Apart from the raw data files as described above, the program maintains a log
file {\file log.ww3}. This file is opened by {\F w3init} (contained in {\F
  w3wave} in {\file w3wavemd.ftn}), which writes some self-explanatory header
information to this file. Each consecutive call to {\F w3wave} adds several
lines to an `action table' in this log file as is shown in
Fig.~\ref{fig:log}. The column identified as `step' shows the discrete time
step considered. The column identified as `pass' identifies the sequence
number of the call to {\F w3wave}; i.e., 3 identifies that this action took
place in the third call to {\F w3wave}. The third column shows the ending time
of the time step. In the input and output columns the corresponding actions of
the model are shown. A {\tt X} identifies that the input has been updated, or
that the output has been performed. A {\tt F} indicates a first field read,
and an {\tt L} identifies the last output. The seven input columns identify
boundary conditions ({\tt b}), wind fields ({\tt w}), water levels ({\tt l}),
current fields ({\tt c}), ice concentrations ({\tt i}), and data for
assimilation ({\tt d}), respectively. Note that data assimilation takes place
at the end of the time step after the wave routine call. The seven output
columns identify gridded output ({\tt g}), point output ({\tt p}), output
along tracks ({\tt t}), restart files ({\tt r}), boundary data ({\tt b}), and
partitioned spectral data ({\tt f}), and output for coupling ({\tt c}),
respectively.

For the multi-grid wave model \citep[][{\file ww3\_multi}]{tol:OMOD08b} a set
of routines is build around the basic wave model routines. The three main
routines are the initialization routine {\F wminit}, a time stepping routine
{\F wmwave} and a finalization routine {\F wmfinl}, with similar functions as
the routines for a single grid as described above. Note that the raw input and
output files are generated for separate grid in the mosaic, and are identified
by replacing the standard file extension '{\file .ww3}' with a unique
identifier for each individual grid as chosen by the user in the 
{\file ww3\_grid.inp} file. Log files are maintained for each individual grid, 
as well as an overall log file {\file log.mww3}.
